﻿using System.Configuration;

namespace Altairis.Nemesis.Gallery.Configuration {

    public class ThumbnailsElement : ConfigurationElementCollection {

        [ConfigurationProperty("enabled", IsRequired = false, DefaultValue = true)]
        public bool Enabled {
            get { return (bool)this["enabled"]; }
            set { this["enabled"] = value; }
        }

        [ConfigurationProperty("defaultSize", IsRequired = true, DefaultValue = "")]
        public string DefaultSize {
            get { return (string)this["defaultSize"]; }
            set { this["defaultSize"] = value; }
        }

        [ConfigurationProperty("cacheTimeout", IsRequired = false, DefaultValue = 60)]
        [IntegerValidator(MinValue = 0)]
        public int CacheTimeout {
            get { return (int)this["cacheTimeout"]; }
            set { this["cacheTimeout"] = value; }
        }

        protected override ConfigurationElement CreateNewElement() {
            return new SizeElement();
        }

        protected override object GetElementKey(ConfigurationElement element) {
            return ((SizeElement)element).Name;
        }
    }

    public class SizeElement : ConfigurationElement {

        [ConfigurationProperty("name", IsRequired = true, IsKey = true)]
        public string Name {
            get { return (string)this["name"]; }
            set { this["name"] = value; }
        }

        [ConfigurationProperty("width", IsRequired = true, DefaultValue = 50)]
        [IntegerValidator(MinValue = 50, MaxValue = 5000)]
        public int Width {
            get { return (int)this["width"]; }
            set { this["width"] = value; }
        }

        [ConfigurationProperty("height", IsRequired = true, DefaultValue = 50)]
        [IntegerValidator(MinValue = 50, MaxValue = 5000)]
        public int Height {
            get { return (int)this["height"]; }
            set { this["height"] = value; }
        }

        [ConfigurationProperty("backgroundColor", IsRequired = false, DefaultValue = "Transparent")]
        public System.Drawing.Color BackgroundColor {
            get { return (System.Drawing.Color)this["backgroundColor"]; }
            set { this["backgroundColor"] = value; }
        }

    }

}